package de.dailab.graphworld.ontology.exceptions;

import de.dailab.graphworld.ontology.Node;

/**
 * MoveException describes some common errors that can occur during move requests.
 * @author jakob
 *
 */
public class MoveException extends GraphWorldException {
	private static final long serialVersionUID = -6788861239965624539L;

	/** Problem describes the reason this exception was thrown */
	public enum Problem {
		/** indicates a position is already used */
		BLOCKED ("This position is already in use."),
		/** indicates that the target position does not exist */
		TARGET_INVALID ("The new position does not exist in the graph!"),
		/** indicates that the target position is not a neighbour of the current position */
		TARGET_NOT_NEIGHBOUR ("Target position is not a neighbour of current position!");
		
		private String message;
		
		public String getMessage() {
			return message;
		}

		private Problem(String message) {
			this.message = message;
		}
	}
	
	private MoveException.Problem problem;

	public MoveException (Problem problem, Node position) {
		super(problem.getMessage(), position);
		this.problem = problem;
	}
	
	public MoveException.Problem getProblem() {
		return problem;
	}
}
